﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="dnTaoMoiSP.ascx.cs" Inherits="uicontrol_dnTaoMoiSP" %>
<asp:SqlDataSource ID="dsSP" runat="server" ConnectionString="<%$ ConnectionStrings:evaConn %>" 
    SelectCommand="SELECT MaSanPham, TenSanPham, KyThuatSanXuat, ThiTruong, TieuChuanSanPham, NamSanXuat FROM SanPham WHERE (Status = 1) AND (MaDoanhNghiep = @MaDoanhNghiep) ORDER BY TenSanPham"  
    UpdateCommand="UPDATE SanPham SET Status = 0 WHERE (MaSanPham = @MaSanPham)"    >
    <SelectParameters>
        <asp:SessionParameter DefaultValue="0" Name="MaDoanhNghiep" SessionField="CompanyID" />
    </SelectParameters>    
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsSP_Info" runat="server" ConnectionString="<%$ ConnectionStrings:evaConn %>" 
    SelectCommand="SELECT MaSanPham, TenSanPham, KyThuatSanXuat, ThiTruong, TieuChuanSanPham, MaHoiDong, NamSanXuat FROM SanPham WHERE (Status = 1) AND (MaSanPham =@MaSanPham)" 
    UpdateCommand="UPDATE SanPham SET TenSanPham = @TenSanPham, KyThuatSanXuat = @KyThuatSanXuat, ThiTruong = @ThiTruong, TieuChuanSanPham = @TieuChuanSanPham, NamSanXuat = @NamSanXuat,MaHoiDong = @MaHoiDong WHERE (MaSanPham = @MaSanPham)" >
    <UpdateParameters>
        <asp:ControlParameter ControlID="txtTenSP" Name="TenSanPham" PropertyName="Text" />
        <asp:ControlParameter ControlID="txtCongNghe" Name="KyThuatSanXuat" PropertyName="Text" />
        <asp:ControlParameter ControlID="txtThiTruong" Name="ThiTruong" PropertyName="Text" />
        <asp:ControlParameter ControlID="txtTieuChuanSP" Name="TieuChuanSanPham" PropertyName="Text" />
        <asp:ControlParameter ControlID="txtNamSX" Name="NamSanXuat" PropertyName="Text" />
        <asp:ControlParameter ControlID="ddlHD" Name="MaHoiDong" PropertyName="SelectedValue" />
        <asp:SessionParameter Name="MaSanPham" SessionField="spID" />
    </UpdateParameters>
    <SelectParameters>
        <asp:SessionParameter Name="MaSanPham" SessionField="spID" />
    </SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsHD" runat="server" ConnectionString="<%$ ConnectionStrings:evaConn %>" 
    SelectCommand="SELECT MaHoiDong, TenHoiDong, MaDoanhNghiep FROM HoiDong WHERE (MaDoanhNghiep = @MaDoanhNghiep) AND (Status=1)">
    <SelectParameters>
        <asp:SessionParameter DefaultValue="0" Name="MaDoanhNghiep" SessionField="CompanyID" />
    </SelectParameters>
</asp:SqlDataSource>
<table style="width:600px">
    <tr>
        <td colspan="3">
            <asp:Label ID="Label7" runat="server" CssClass="LabelTitle" Text="TẠO MỚI SẢN PHẨM CHO DOANH NGHIỆP"></asp:Label></td>
    </tr>
    <tr>
        <td> &nbsp;
        </td>
        <td>
        </td>
        <td>
        </td>
    </tr>
    <tr>
        <td style="width:30%">
            <asp:Label ID="Label1" runat="server" CssClass="Label" Text="Tên Sản phẩm"></asp:Label></td>
        <td style="width:45%">
            <asp:TextBox ID="txtTenSP" runat="server" CssClass="Textbox" MaxLength="100"></asp:TextBox></td>
        <td>
            <asp:RequiredFieldValidator ID="rfvTenSP" runat="server" CssClass="ValidateLabel"
                ErrorMessage="Không được trống" ControlToValidate="txtTenSP" Display="Dynamic"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label2" runat="server" CssClass="Label" Text="Tên Hội đồng"></asp:Label></td>
        <td>
            <asp:DropDownList ID="ddlHD" runat="server" CssClass="DropdownList" DataSourceID="dsHD" DataTextField="TenHoiDong" DataValueField="MaHoiDong">
            </asp:DropDownList></td>
        <td>
        </td>
    </tr>
    <tr>
        <td style="height: 26px">
            <asp:Label ID="Label3" runat="server" CssClass="Label" Text="Công nghệ sản xuất"></asp:Label></td>
        <td style="height: 26px">
            <asp:TextBox ID="txtCongNghe" runat="server" CssClass="Textbox" MaxLength="500"></asp:TextBox></td>
        <td style="height: 26px">
            <asp:RequiredFieldValidator ID="rfvCongnghe" runat="server" ControlToValidate="txtCongNghe"
                CssClass="ValidateLabel" ErrorMessage="Không được trống" Display="Dynamic"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label4" runat="server" CssClass="Label" Text="Thị trường"></asp:Label></td>
        <td>
            <asp:TextBox ID="txtThiTruong" runat="server" CssClass="Textbox" MaxLength="500"></asp:TextBox></td>
        <td>
            <asp:RequiredFieldValidator ID="rfvThiTruong" runat="server" ControlToValidate="txtThiTruong"
                CssClass="ValidateLabel" ErrorMessage="Không được trống" Display="Dynamic"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label5" runat="server" CssClass="Label" Text="Tiêu chuẩn sản phẩm"></asp:Label></td>
        <td>
            <asp:TextBox ID="txtTieuChuanSP" runat="server" CssClass="Textbox" MaxLength="500"></asp:TextBox></td>
        <td>
            <asp:RequiredFieldValidator ID="rfvTieuChuan" runat="server" ControlToValidate="txtTieuChuanSP"
                CssClass="ValidateLabel" ErrorMessage="Không được trống" Display="Dynamic"></asp:RequiredFieldValidator></td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label6" runat="server" CssClass="Label" Text="Năm sản xuất"></asp:Label></td>
        <td>
            <asp:TextBox ID="txtNamSX" runat="server" CssClass="Textbox" MaxLength="4"></asp:TextBox></td>
        <td>
            <asp:RequiredFieldValidator ID="rfvnamsx" runat="server" ControlToValidate="txtNamSX"
                CssClass="ValidateLabel" ErrorMessage="Không được trống" Display="Dynamic"></asp:RequiredFieldValidator>
            <asp:RegularExpressionValidator ID="revNamsx" runat="server" ControlToValidate="txtNamSX"
                CssClass="ValidateLabel" Display="Dynamic" ErrorMessage="Năm SX không hợp lệ"
                ValidationExpression="([1][9][0-9][0-9])|([2][0-1][0-9][0-9])"></asp:RegularExpressionValidator></td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="lblResult" runat="server" CssClass="LabelResult"></asp:Label></td>
        <td>
        </td>
        <td>
        </td>
    </tr>
    <tr>
        <td>
            <asp:Button ID="btnNew" runat="server" CssClass="Button" Text="Tạo mới" OnClick="btnNew_Click" />
            <asp:Button ID="btnUpdate" runat="server" CssClass="Button" Text="Cập nhật" OnClick="btnUpdate_Click" Visible="False" /></td>
        <td>
            <asp:Button ID="btnCancel" runat="server" CssClass="Button" Text="Làm lại" CausesValidation="False" OnClick="btnCancel_Click" /></td>
        <td>
        </td>
    </tr>
    <tr>
        <td>
        </td>
        <td>
        </td>
        <td>
        </td>
    </tr>
</table>
<table style="width: 600px">
    <tr>
        <td style="width: 100%">
            <asp:Label ID="Label8" runat="server" CssClass="LabelResult" Text="Danh sách sản phẩm của Doanh nghiệp"></asp:Label></td>
    </tr>
    <tr>
        <td>
            <asp:GridView ID="grvSP" runat="server" AllowPaging="True" AutoGenerateColumns="False"
                DataKeyNames="MaSanPham" DataSourceID="dsSP" PageSize="5" OnRowDataBound="grvSP_RowDataBound" OnRowCommand="grvSP_RowCommand" OnPageIndexChanging="grvSP_PageIndexChanging" CssClass="Grv">
                <Columns>
                    <asp:BoundField DataField="MaSanPham" HeaderText="MaSanPham" InsertVisible="False"
                        ReadOnly="True" SortExpression="MaSanPham" />
                    <asp:BoundField DataField="TenSanPham" HeaderText="T&#234;n Sản phẩm" SortExpression="TenSanPham" />
                    <asp:BoundField DataField="KyThuatSanXuat" HeaderText="Kỹ thuật SX" SortExpression="KyThuatSanXuat" />
                    <asp:BoundField DataField="ThiTruong" HeaderText="Thị trường" SortExpression="ThiTruong" />
                    <asp:BoundField DataField="TieuChuanSanPham" HeaderText="Ti&#234;u chuẩn" SortExpression="TieuChuanSanPham" />
                    <asp:BoundField DataField="NamSanXuat" HeaderText="Năm SX" SortExpression="NamSanXuat" />                    
                    <asp:TemplateField HeaderText="Chức năng">
                    <ItemTemplate>
                        <asp:ImageButton ID="sua" CommandArgument='<%# Eval("MaSanPham") %>' CommandName="Sua" runat="server" ImageUrl="~/App_Themes/Default/Css/images/edit.gif" CausesValidation="false" AlternateText="Sửa lại thông tin của Sản phẩm này"/>
                        <asp:ImageButton ID="update" CommandArgument='<%# Eval("MaSanPham") %>' CommandName="Update" runat="server" ImageUrl="~/App_Themes/Default/Css/images/delete.gif" CausesValidation="false" AlternateText="Xóa Sản phẩm này"/>
                        <asp:ImageButton ID="giacong" CommandArgument='<%# Eval("MaSanPham") %>' CommandName="GiaCong" runat="server" ImageUrl="~/App_Themes/Default/Css/images/HoSo.gif" CausesValidation="false" AlternateText="Xem danh sách các Bước Gia công của Sản phẩm này"/>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>    
                </Columns>
                <PagerStyle CssClass="GrvPagerStyle"/>
                <HeaderStyle CssClass="GrvHeader" />
                <RowStyle CssClass="GrvRowStyle"/>
                <AlternatingRowStyle CssClass="GrvAlternatingRowStyle" />
            </asp:GridView>
        </td>
    </tr>
    <tr>
        <td>
        </td>
    </tr>
</table>
